var t = require("../../../../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Component({
    properties: {
        keywork: {
            type: null
        },
        memberId: {
            type: null
        }
    },
    data: {
        strUrl: "plugin.customer-center.frontend.controllers.customer.couponsOfMemberByStatusV2",
        getConfig: {
            client: "work",
            type: 17
        },
        couponList: [],
        sidebarList: [],
        json: {
            page: 1,
            coupon_type: 0
        },
        loading: !1,
        finished: !1
    },
    lifetimes: {
        attached: function() {
            var t = wx.getStorageSync("langIndex");
            this.setData({
                language: t.en
            }), this.getData();
        }
    },
    methods: {
        getData: function() {
            var e = this;
            if (!this.data.finished || !this.data.loading) {
                this.data.loading = !0;
                var s = {};
                "customer" == this.data.keywork && (this.data.strUrl = "plugin.customer-center.frontend.controllers.customer.couponsOfMemberByStatusV2", 
                this.data.json.member_id = this.data.memberId, s = t({}, this.data.json));
                var n = a.getNetAddresss(this.data.strUrl);
                a._postNetWork({
                    url: n,
                    data: s,
                    success: function(t) {
                        var a = t.data;
                        if (1 == a.result && a.data.data) {
                            var s = a.data.data;
                            (e.data.json.page >= s.last_page || s.data.length < s.per_page) && e.setData({
                                finished: !0
                            }), e.setData({
                                couponList: s.data,
                                sidebarList: a.data.search_array,
                                "json.page": ++e.data.json.page
                            }), console.log(e.data.couponList);
                        } else e.setData({
                            finished: !0
                        }), wx.showToast({
                            icon: "none",
                            title: a.msg,
                            duration: 1500
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        },
        changeCouponType: function(t) {
            var a = t.detail;
            this.setData({
                "json.coupon_type": a
            }), this.getParamInit(), this.getData();
        },
        loadMore: function() {
            this.getData();
        },
        getParamInit: function() {
            this.setData({
                listData: [],
                "json.page": 1,
                loading: !1,
                finished: !1
            });
        }
    }
});